#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#pragma instrument function(kernel, main)

// addition de vecteurs
void kernel(double a[], double b[], double c[], int N, int blockDim, int gridDim)
{
		int i;
    for(i = 0 ; i < /*blockDim*gridDim*/ 1024 ; i++)
    {
				c[i] = a[i] + b[i];
    }
}

int main(int argc, char **argv)
{
    int N = 1024;
    int sz_in_bytes = N*sizeof(double);

    double *h_a, *h_b, *h_c; 	// host
    h_a = (double*)malloc(sz_in_bytes);	// allocation sur l'hôte
    h_b = (double*)malloc(sz_in_bytes);
    h_c = (double*)malloc(sz_in_bytes);

	int i;
    // Initiate values on h_a and h_b
    for(i = 0 ; i < /* N*/ 1000 ; i++)
    {
		h_a[i] = 1./(1.+i);
		h_b[i] = (i-1.)/(i+1.);
    }
	
	int blockDim = 64;
	int gridDim = (N + blockDim - 1)/blockDim;
	
	
    kernel(h_a, h_b, h_c, N, blockDim, gridDim);

	// affichage des résultats
  /*  for(i = 0 ; i < N ; i++)
    {
		printf("[%d] = %f\t", i, h_c[i]);
    }	*/
	

    free(h_a);
    free(h_b);
    free(h_c);

    return 0;
}
